package com.quickask.entity;

import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * Created by NaSa on 2015/9/23.
 */
@Entity
@Table(name = "asknow_user_privilege", schema = "", catalog = "quickask")
@org.hibernate.annotations.Cache(usage= CacheConcurrencyStrategy.READ_WRITE, region = "com.quickask.entity.AsknowUserPrivilegeEntity")
public class AsknowUserPrivilegeEntity implements Serializable {
    private int userId;  //用户id
    private String userNickname; //用户昵称
    private String userIcon;  //用户头像地址
    private Byte userSex;  //用户性别
    private Integer userAge;  //用户年龄
    private Integer userPoint;  //用户积分
    private Integer userRank;  //用户等级
    private Byte userLoginState;  //用户登录状态,0未登录，1已登录, 默认0
    private Timestamp userLastLoginTime;  //用户最后一次登录时间
    private String refreshToken; //用户申请或修改非普通资源的token
    private Timestamp userRefreshTokenCreateTime;  //用户refreshToken创建时间
    private Byte userRefreshTokenIsExpire;  //用户refreshToken是否已过期,需要数据库编写触发器自动触发过期,0已过期，1未过期，默认0
    private Integer userRefreshTokenExpireTime;  //refreshToken过期时间，单位秒
    private String userAlia;  //用户jpush别名


    @Id
    @Column(name = "userId", nullable = false, insertable = true, updatable = true)
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Column(name = "userNickname", nullable = true, insertable = true, updatable = true, length = 50)
    public String getUserNickname() {
        return userNickname;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    @Column(name = "userIcon", nullable = true, insertable = true, updatable = true, length = 255)
    public String getUserIcon() {
        return userIcon;
    }

    public void setUserIcon(String userIcon) {
        this.userIcon = userIcon;
    }

    @Column(name = "userSex", nullable = true, insertable = true, updatable = true, scale = 1)
    public Byte getUserSex() {
        return userSex;
    }

    public void setUserSex(Byte userSex) {
        this.userSex = userSex;
    }

    @Column(name = "userAge", nullable = true, insertable = true, updatable = true)
    public Integer getUserAge() {
        return userAge;
    }

    public void setUserAge(Integer userAge) {
        this.userAge = userAge;
    }

    @Column(name = "userPoint", nullable = true, insertable = true, updatable = true)
    public Integer getUserPoint() {
        return userPoint;
    }

    public void setUserPoint(Integer userPoint) {
        this.userPoint = userPoint;
    }

    @Column(name = "userLoginState", nullable = true, insertable = true, updatable = true, scale = 1)
    public Byte getUserLoginState() {
        return userLoginState;
    }

    public void setUserLoginState(Byte userLoginState) {
        this.userLoginState = userLoginState;
    }

    @Column(name = "userLastLoginTime", nullable = true, insertable = true, updatable = true)
    public Timestamp getUserLastLoginTime() {
        return userLastLoginTime;
    }

    public void setUserLastLoginTime(Timestamp userLastLoginTime) {
        this.userLastLoginTime = userLastLoginTime;
    }

    @Column(name = "userRank", nullable = true, insertable = true, updatable = true)
    public Integer getUserRank() {
        return userRank;
    }

    public void setUserRank(Integer userRank) {
        this.userRank = userRank;
    }

    @Column(name = "refreshToken", nullable = true, insertable = true, updatable = true)
    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    @Column(name = "userRefreshTokenCreateTime", nullable = true, insertable = true, updatable = true)
    public Timestamp getUserRefreshTokenCreateTime() {
        return userRefreshTokenCreateTime;
    }

    public void setUserRefreshTokenCreateTime(Timestamp userRefreshTokenCreateTime) {
        this.userRefreshTokenCreateTime = userRefreshTokenCreateTime;
    }

    @Column(name = "userRefreshTokenIsExpire", nullable = true, insertable = true, updatable = true, scale = 1)
    public Byte getUserRefreshTokenIsExpire() {
        return userRefreshTokenIsExpire;
    }

    public void setUserRefreshTokenIsExpire(Byte userRefreshTokenIsExpire) {
        this.userRefreshTokenIsExpire = userRefreshTokenIsExpire;
    }

    @Column(name = "userRefreshTokenExpireTime", nullable = true, insertable = true, updatable = true)
    public Integer getUserRefreshTokenExpireTime() {
        return userRefreshTokenExpireTime;
    }

    public void setUserRefreshTokenExpireTime(Integer userRefreshTokenExpireTime) {
        this.userRefreshTokenExpireTime = userRefreshTokenExpireTime;
    }

    @Column(name = "userAlia", nullable = true, insertable = true, updatable = true, length = 100)
    public String getUserAlia() {
        return userAlia;
    }

    public void setUserAlia(String userAlia) {
        this.userAlia = userAlia;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AsknowUserPrivilegeEntity)) return false;

        AsknowUserPrivilegeEntity that = (AsknowUserPrivilegeEntity) o;

        if (userId != that.userId) return false;
        if (userNickname != null ? !userNickname.equals(that.userNickname) : that.userNickname != null) return false;
        if (userIcon != null ? !userIcon.equals(that.userIcon) : that.userIcon != null) return false;
        if (userSex != null ? !userSex.equals(that.userSex) : that.userSex != null) return false;
        if (userAge != null ? !userAge.equals(that.userAge) : that.userAge != null) return false;
        if (userPoint != null ? !userPoint.equals(that.userPoint) : that.userPoint != null) return false;
        if (userRank != null ? !userRank.equals(that.userRank) : that.userRank != null) return false;
        if (userLoginState != null ? !userLoginState.equals(that.userLoginState) : that.userLoginState != null)
            return false;
        if (userLastLoginTime != null ? !userLastLoginTime.equals(that.userLastLoginTime) : that.userLastLoginTime != null)
            return false;
        if (refreshToken != null ? !refreshToken.equals(that.refreshToken) : that.refreshToken != null) return false;
        if (userRefreshTokenCreateTime != null ? !userRefreshTokenCreateTime.equals(that.userRefreshTokenCreateTime) : that.userRefreshTokenCreateTime != null)
            return false;
        if (userRefreshTokenIsExpire != null ? !userRefreshTokenIsExpire.equals(that.userRefreshTokenIsExpire) : that.userRefreshTokenIsExpire != null)
            return false;
        if (userRefreshTokenExpireTime != null ? !userRefreshTokenExpireTime.equals(that.userRefreshTokenExpireTime) : that.userRefreshTokenExpireTime != null)
            return false;
        return !(userAlia != null ? !userAlia.equals(that.userAlia) : that.userAlia != null);

    }

    @Override
    public int hashCode() {
        int result = userId;
        result = 31 * result + (userNickname != null ? userNickname.hashCode() : 0);
        result = 31 * result + (userIcon != null ? userIcon.hashCode() : 0);
        result = 31 * result + (userSex != null ? userSex.hashCode() : 0);
        result = 31 * result + (userAge != null ? userAge.hashCode() : 0);
        result = 31 * result + (userPoint != null ? userPoint.hashCode() : 0);
        result = 31 * result + (userRank != null ? userRank.hashCode() : 0);
        result = 31 * result + (userLoginState != null ? userLoginState.hashCode() : 0);
        result = 31 * result + (userLastLoginTime != null ? userLastLoginTime.hashCode() : 0);
        result = 31 * result + (refreshToken != null ? refreshToken.hashCode() : 0);
        result = 31 * result + (userRefreshTokenCreateTime != null ? userRefreshTokenCreateTime.hashCode() : 0);
        result = 31 * result + (userRefreshTokenIsExpire != null ? userRefreshTokenIsExpire.hashCode() : 0);
        result = 31 * result + (userRefreshTokenExpireTime != null ? userRefreshTokenExpireTime.hashCode() : 0);
        result = 31 * result + (userAlia != null ? userAlia.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "AsknowUserPrivilegeEntity{" +
                "userId=" + userId +
                ", userNickname='" + userNickname + '\'' +
                ", userIcon='" + userIcon + '\'' +
                ", userSex=" + userSex +
                ", userAge=" + userAge +
                ", userPoint=" + userPoint +
                ", userRank=" + userRank +
                ", userLoginState=" + userLoginState +
                ", userLastLoginTime=" + userLastLoginTime +
                ", refreshToken='" + refreshToken + '\'' +
                ", userRefreshTokenCreateTime=" + userRefreshTokenCreateTime +
                ", userRefreshTokenIsExpire=" + userRefreshTokenIsExpire +
                ", userRefreshTokenExpireTime=" + userRefreshTokenExpireTime +
                ", userAlia='" + userAlia + '\'' +
                '}';
    }
}
